const { rejects } = require('assert');
const mysql = require('mysql');
const connection = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: '123456',
    database: 'vue-serve'
});

const mysqlApi = function (sqlStr) {
    return new Promise((resolve, rejects) => {
        connection.query(sqlStr, function (error, data) {
            if (error) rejects(error);
            else resolve(data);
        })
    })
}

module.exports = {
    connection,
    mysqlApi
}
